MessageBundle = function(container, className, debugMode)
{
	if(debugMode)
		alert('MessageBundle params : ' + this.__formatArguments(arguments));
		
  	this.messages = new Array();  	
  	this.className = ( className != null &&  className != undefined ) ? className:'info';  	
  	this.replaceContainerHtml = true;  	
  	this.messageHeader = '';
  	
  	if(debugMode != null)
		this.debugMode = debugMode;
	else
		this.debugMode = false;
	
	if($(container) != null)
		this.container = $(container);	
	else	
		alert('MessageBundle - Impossible to find container[' + container + ']');
}

MessageBundle.prototype = {

setMessage : function(message)
{
	this.messages.push(message); 
	return this;
}
,
setMessageHeader : function(message)
{
	this.messageHeader = message; 
	return this;
}
,
displayMessages : function()
{	
	var mainDiv = document.createElement('div');
		
	if(this.messages.length > 0)
	{
		ul = document.createElement('ul');
		
		innerDiv = document.createElement('div');
		innerDiv.innerHTML = this.messageHeader;
		
		for(i = 0; i < this.messages.length; i++)
		{
			li = document.createElement('li');
			li.innerHTML = this.messages[i];
			ul.appendChild(li);
		}
		
		innerDiv.appendChild(ul);
		
		mainDiv.appendChild(innerDiv);	
						
		this.container.innerHTML = '';
				
		this.container.appendChild(mainDiv);		
			
		Element.addClassName(mainDiv, this.className);
	}
		
	if(this.debugMode)
		alert(this.container.innerHTML.replace('>','>\n'));
}
,
// {{{ __formatArguments(arguments)
__formatArguments : function(arguments)
{
	var elements = new Array();

  	for (var i = 0; i < arguments.length; i++) 
  	{
    	var element = arguments[i];    
    	elements.push(element);
  	}
  
  	return elements.inspect();
}

}// end class 

/* ------------------------------------------------------------------ */